package data;

import java.lang.reflect.Type;

import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;

public class SaveResponse extends Response {
	private int mOrderId;

	public SaveResponse() {
		mExitCode = 0;
		mOrderId = 0;
	}
	
	public SaveResponse(int exitCode, int orderId) {
		mExitCode = exitCode;
		mOrderId = orderId;
	}
	
	public int getOrderId() {
		return mOrderId;
	}

	public final static JsonDeserializer<SaveResponse> deserializer = new JsonDeserializer<SaveResponse>() {

		@Override
		public SaveResponse deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
				throws JsonParseException {
			
			int exitCode = json.getAsJsonObject().get("exitCode").getAsInt();
			int dbId = json.getAsJsonObject().get("orderId").getAsInt();
            return new SaveResponse(exitCode, dbId);
		}
	};
}
